﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ActorManager
{
    Dictionary<uint,Actor> actorDic = new Dictionary<uint, Actor>();
    public uint controlPlayerId;

    public void Register(uint netId, Actor actor, bool isSelf)
    {
        if (isSelf)
        {
            controlPlayerId = netId;
        }
        actorDic.Add(netId, actor);
    }

    public Actor GetActor(uint id)
    {
        return actorDic[id];
    }

    public Actor GetLocalPlayer()
    {
        return actorDic[controlPlayerId];
    }
    
    public void TakeDamage(uint id, int damage)
    {
        actorDic[id].propertyComponent.OnHurt(damage);
    }
    
    public void Reload(uint id)
    {
        actorDic[id].gunComponent.ReloadAnim();
    }

    public GameObject GetGetLocalPlayerCamera()
    {
        if (actorDic[controlPlayerId] != null)
        {
            return actorDic[controlPlayerId].fpsCamara;
        }
        return null;
    }
}
